Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add id and comment #110

Merged
merged 8 commits into from
Aug 31, 2023
Merged

Add id and comment #110

merged 8 commits into from
Aug 31, 2023

Conversation

rhpvorderman
Copy link
Collaborator

@rhpvorderman rhpvorderman commented Aug 30, 2023

You had something like this in mind?

EDIT:
fixes #10

Copy link
Owner

@marcelm marcelm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, very nice! This will be really nice to have. We should make a release as soon as this is merged.

This also needs a changelog and documentation update. (I can do that if you don’t have time over the coming days.)

self._comment = ""
else:
comment_length = name_length - (id_length + 1)
comment_start = name + id_length + 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this assumes that there’s only one whitespace between the id and the comment. I’d assume this is true most of the time, but I think we need to be a bit more defensive.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally, a use for strspn!

comment_start = name + id_length + 1
self._comment = PyUnicode_New(comment_length , 127)
memcpy(PyUnicode_DATA(self._comment), comment_start, comment_length)
# Cached but nothing is internally empty string, expose externally as None
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t get the comment. Maybe just remove? Would be ok

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try to make it more clear in the comment. It is a rather odd design choice so it needs one, I think.

(SequenceRecord("name ", "A", "="), None),
(SequenceRecord("name ", "A", "="), " "),
(SequenceRecord("name", "A", "="), None),
(SequenceRecord("AotC I hate sand!", "A", "="), "I hate sand!"),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

@marcelm marcelm Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I got the Star Wars reference, but didn’t know the song (and now it’ll be stuck in my head for the rest of the day ...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well you could always listen to "Last jedi knight" by the same musician to get it out of your head again ;-).

@rhpvorderman
Copy link
Collaborator Author

All done!

@marcelm
Copy link
Owner

marcelm commented Aug 31, 2023

I’m happy with this now! Let’s also make a release soon.

@marcelm marcelm merged commit 47b6976 into marcelm:main Aug 31, 2023
16 checks passed
@rhpvorderman rhpvorderman mentioned this pull request Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Sequence.id attribute
2 participants